﻿using System;
using Microsoft.Xna.Framework;

namespace ThreeDContentPipeline
{
    public class KeyFrameMeshWriter : ContentTypeWriter<KeyFrameMeshContent>
    {
        public override void Write(KeyFrameMeshContent value, ContentWriter writer)
        {
            writer.WriteArray(value.Indices.ToArray());

            foreach (Vector2 texCoord in value.TextureCoordinates)
            {
                writer.Write(texCoord);
            }

            writer.Write(value.KeyFrames.Count);
            foreach (KeyFrameContent keyFrame in value.KeyFrames)
            {
                writer.Write(keyFrame.Positions.Count);
                foreach (Vector3 position in keyFrame.Positions)
                {
                    writer.Write(position);
                }
            }
        }

        public override string ContentReaderName()
        {
            return "ThreeDWorld.KeyFrameMeshReader, ThreeDWorld";
        }
    }
}
